home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13379 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: po.CWRU.Edu!lem
  2. From: lem@po.CWRU.Edu (Leonard E. Marinis)
  3. Newsgroups: comp.lang.c,comp.unix.programmer
  4. Subject: tcp/ip woes.
  5. Date: 7 Apr 1996 19:19:56 GMT
  6. Organization: Case Western Reserve University, Cleveland, OH (USA)
  7. Message-ID: <4k94gs$nm0@madeline.INS.CWRU.Edu>
  8. Reply-To: lem@po.CWRU.Edu (Leonard E. Marinis)
  9. NNTP-Posting-Host: christopher.ins.cwru.edu
  10.  
  11.  
  12. hi, i've been struggling with this questions
  13. for a few days now and was hoping to get some
  14. insight from the group here..
  15.  
  16. currently i'm running linux 1.2.11, and in the
  17. process of completing my first tcp/ip oriented
  18. program. the program broadcasts a ping, then
  19. prints to screen the numeric and DNS entries
  20. of the replying hosts.. this is the piece of
  21. code that giving me headaches -
  22.  
  23.  /* check it out & process if ICMP_ECHOREPLY */
  24.         mp=(struct icmphdr *)buff+20;
  25.         if(!mp->type) {
  26.                 from_host=inet_ntoa(from.sin_addr);
  27.                 host_info=gethostbyaddr((char *)&from.sin_addr, sizeof(from.sin_addr), AF_INET); 
  28.                 printf("\nreply from %s\t", from_host);
  29.                 if(strlen(from_host) < 13)
  30.                         printf("\t");
  31.                 printf("[%s]", host_info->h_name);
  32.                 
  33.         } else 
  34.                 printf("\nnon ICMP_ECHOREPLY packet");
  35.  
  36. the strange thing is, it works fine. until about 80 host replies
  37. come in - at which time the process segmentation faults
  38. and quits. if i had any clue about how to analyze a core file, i would.
  39. (any suggestions where i could learn more about this?)
  40.  
  41. anyhow, i've narrowed it down to the printf("[%s]", host_info->h_name);
  42. by process of elimination and use of commenting out code. the only thing
  43. i could possibly think is happening is that perhaps the replies are coming
  44. in too fast and overflowing a buffer of sorts i am not aware of.
  45.  
  46. host_info, by the way, is declared as struct hostent *host_info;
  47. any help whatsoever would be appreciated. email responses would
  48. be ideal but i will check the group periodically as well.
  49. oh, and i'd be more than happy to furnish a full copy of the program per request.
  50. grazi,
  51. len marinis
  52. lem@po.cwru.edu
  53.  
  54.  
  55.